

<%def name="siteview(site)">
    <div id="profilesettingsform"></div>
    <div id="profilesettings">
        <div class="actionbar">
            <span class="h3">Site Settings</span>
            % if site.id == c.user.site_id:
            <div class="boxlinks right"  style="margin-top:-27px;margin-right:-13px;height:25px;">
                <a id="site${site.id}" href="/site/edit/${site.id}">Edit</a>
            </div>
             % endif
        </div>
        <div class="clear"></div>
        <dl>
            <dt>Name:</dt>                  <dd>${site.name}</dd>
            <dt>Email:</dt>                 <dd>${site.email}</dd>
            <dt>Slug:</dt>                 <dd>${site.slug}<img alt="help?" title="This is going to be the url for users to embed this sites javascript" 
                src="/images/icon_help.png" class="demisauce_help_tip" /></dd>
            <dt>Base Url:</dt>              <dd>${h.link_to(site.base_url ,h.url('%s' % str(site.base_url)))}</dd>
            <dt>Comment Url:</dt>              <dd>${h.link_to(site.site_url ,h.url('%s' % str(site.site_url)))}</dd>
            <dt>Description:</dt>            <dd>${site.description}</dd>
            <dt>Site Created:</dt>          <dd>${site.created.strftime("%b %d, %Y") or ''}</dd>
            <dt>ApiKey:</dt>                <dd>${site.key}</dd>
            <dt>Is Public:</dt>                <dd>${(site and site.public) or 'False'}</dd>
            % if c.user and c.user.issysadmin:
            <dt>Is Enabled:</dt>          <dd id="site">${(site and site.enabled) or 'False'},  
                                                % if not site.enabled:
                                                <a href="javascript:void(0)" id="enablesite" siteid="${site.id}">Enable</a>
                                                % else:
                                                 
                                                % endif

                                                <img alt="help?" title="Enabling the site sends a welcome email to user and allows them to start using demisauce" 
                                                    src="/images/icon_help.png" class="demisauce_help_tip" />
                                          </dd>
            % endif
        </dl>
        <div class="clear"></div>
        <script type="text/javascript">
            $(document).ready(function() {
                $('.demisauce_help_tip').tooltip({ track: true, delay: 0, showURL: false, 
                    showBody: " - ", opacity: 0.85,width: 260});
                
                $("#enablesite").click(function() {
                    var siteid = $(this).attr('siteid');
                    $.ajax({type: "POST",url: "/admin/enablesite/" + siteid ,
                        data: "siteid=" + siteid,
                        success: function(msg){
                            $.showmessage( msg );
                        }
                    });
                });
            });
        </script>
    </div>
</%def>

<%def name="table(items)">
<table class="dsadmin">
    <thead>
        <tr >
            <th scope="col">Site</th>
            <th scope="col">Enabled</th>
            <th scope="col"></th>
            <th scope="col">Date</th>
            <th scope="col"></th>
        </tr>
    </thead>
    <tbody>
    % for item in items:
        <tr class="${h.cycle("", "alternate") }">
            <td>${h.link_to(item.name, h.url(controller="site",action="view", id=item.id), class_="title")}</td>
            <td>${item.enabled}</td>
            <td>${h.link_to('Edit', h.url(controller="site",action="edit", id=item.id), class_="title")}</td>
            <td>${(item.created).strftime("%b %d, %Y") or ''}</td>
            <td>${h.simple_format(h.truncate(item.description, 30))}</td>
        </tr>
        
    % endfor
    </tbody>
</table>
</%def>
<%def name="sitelist(items)">
    % for item in items:

        <div id="item_${item.id}" class="nodedisplay clearfix">
            ${h.link_to(item.name, h.url(controller="site",action="view", id=item.id), class_="title")}, 
            enabled = ${item.enabled}
            ${h.link_to('Edit', h.url(controller="site",action="edit", id=item.id), class_="title")}, more here
            <p class="description">
                ${h.simple_format(item.description)}
            </p>
        </div>

    % endfor
</%def>

<%def name="comment_config(site)">
<textarea class="python_code" rows=15 cols=130>

<script type="text/javascript" src="${h.base_url()}/comment/js/${site.slug}"></script>
<script type="text/javascript">
    
    window.onload=function () {
        DEMISAUCE.comment.init({
            site_slug: '${site.slug}',
            base_url: '${c.base_url}', //  the base url of the demisauce server
        })
    };
    
</script>

</textarea>

</%def>
<%def name="help_config(site)">

<div class="actionbar right" id="actionbarhelp" style="height:34px; ">
    <div class="boxlinks boxlinks_tabs"  style="margin-top:4px;">
        <ul>
            <li><a href="#" id="help_show_all">Show all</a></li>
            <li><a href="javascript:void(0);" id="help_show_topinfo">Show Rating</a></li>
            <li><a href="javascript:void(0);" id="help_show_rating">Show Top Articles</a></li>
            <li><a href="#" id="showbothhelp">Hide Both</a></li>
        </ul>

        <script type="text/javascript">
            $(document).ready(function(){
                //&lt;&gt;
                function getHelpJs(rating,topinfo) {
                    var js = '&lt;script type="text/javascript" src="${site.base_url}/js/ds.base.js" /&gt; \n\
&lt;script type="text/javascript" src="${site.base_url}/js/facebox.js" /&gt; \n\
&lt;script type="text/javascript" src="${site.base_url}/css/ds.widgets.css" /&gt; \n\
&lt;script type="text/javascript" &gt;  \n\
    jQuery(document).ready(function($) { \n\
        $("a[rel*=facebox]").dshelp({opacity : .1, \n';
                if (rating == false){
                    js += '             rating: false, \n'
                }
                if (topinfo == false){
                    js += '             topinfo: false, \n'
                }
                js += '             base_url: "${site.base_url}", \n\
             site_slug: "${site.slug}", \n\
             use_current_url: true \n\
        }); \n\
    }); \n\
&lt;/script&gt;';
                    return js;
                }
                
                $('#helpconfig_area').html(getHelpJs(true,true));
                $("#help_show_all").click(function() {
                    $('#helpconfig_area').html(getHelpJs(true,true));
                    return false;
                });
                $("#help_show_rating").click(function() {
                    $('#helpconfig_area').html(getHelpJs(false,true));
                });
                $("#help_show_topinfo").click(function() {
                    $('#helpconfig_area').html(getHelpJs(true,false));
                });
                $("#showbothhelp").click(function() {
                    $('#helpconfig_area').html(getHelpJs(false,false));
                    return false;
                });
            });
        </script>
    </div>
</div>
<textarea class="python_code" id="helpconfig_area" rows="15" cols="130">
</textarea>

</%def>
